#include <iostream>
#include <vector>
using namespace std;
// 计数排序
void CountSort(vector<int>& a, int n) {
    int Min = a[0];
    int Max = a[0];
    for(auto& e : a) {
        if(e < Min) {
            Min = e;
        }
        if(e > Max) {
            Max = e;
        }
    }
    vector<int> count(Max - Min + 1, 0);
    vector<int> temp(n);
    for(auto& e : a) {
        count[e - Min]++;
    }
    for(int i = 1; i < Max - Min + 1; i++) {
        count[i] += count[i - 1];
    }
    for(int i = n - 1; i >= 0; i--) {
        int num = a[i];
        temp[count[num - Min] - 1] = num;
        count[num -Min]--;
    }
    a = temp;
}
int main() {
    vector<int> a = {1, 4, 3, 5, 6, 3, 2, 7, 8, 0};
    CountSort(a, 10);
    for(auto& e : a) {
        cout << e << " ";
    }
    return 0;
}